package com.mijie.homi.dao.user;

import java.util.List;
import java.util.HashMap;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.user.ThirdPartAccount;
import com.mijie.homi.common.domain.user.ThirdPartOfficialAccount;

@Repository
@Transactional
public class ThirdPartAccountDao extends IBatisDao {

	public int addThirdPartAccount(ThirdPartAccount account){
		return this.insert("addThirdPartAccount", account);
	}
	
	public ThirdPartAccount getThirdPartAccount(String accountId,int type){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("accountId", accountId);
		parameter.put("type", type);
		return this.selectOne("getThirdPartAccount", parameter);
	}
	
	public int updateThirdPartAccount(ThirdPartAccount account){
		return this.update("updateThirdPartAccount", account);
	}
	
	public int followThirdPartOfficialAccount(String accountId,int type){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("accountId", accountId);
		parameter.put("type", type);
		return this.update("followThirdPartOfficialAccount", parameter);
	}
	
	public List<ThirdPartAccount> listThirdPartAccountByUser(int userId){
		return this.selectList("listThirdPartAccountByUser", userId);
	}
	
	public ThirdPartOfficialAccount getOfficialAccount(int type){
		return this.selectOne("getOfficialAccount", type);
	}
}
